package com.wyg.jdbc;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

import javax.swing.plaf.synth.SynthSeparatorUI;

public class Jdbc {
	
	public static String driver="oracle.jdbc.driver.OracleDriver";
	public static String url="jdbc:oracle:thin:@127.0.0.1:1521:xe";
	public static String user="iotek";
	public static String password="iotek";
	public static Connection conn=null;
	public static PreparedStatement pstmt=null;
	
	public static void getConnection(){
		try {
			Class.forName(driver);
			conn=DriverManager.getConnection(url, user, password);
			
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
	
	//查询
	public static ResultSet query(String sql){
		ResultSet rs=null;
		try {
			pstmt=conn.prepareStatement(sql);
			rs=pstmt.executeQuery();
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return rs;
	}

	public static void close(){
		try {
			conn.close();
		} catch (SQLException e) {
			e.printStackTrace();
		}
	}
	
	public static void insertIntoUserCar(String xinghao,String baojia){
		
	}

}
